package optimization.ifelse.strategy;

import optimization.ifelse.RefelDbTypeEnum;
import java.util.HashMap;
import java.util.Map;

public class StrategySingleton {

    /*
    * 单例模式
    * */
    private static StrategySingleton instance=null;

    private StrategySingleton(){
    }

    private static synchronized void syncInit() {
        if (instance == null) {
            instance = new StrategySingleton();
        }
    }

    public static StrategySingleton getInstance() {
        if (instance == null) {
            syncInit();
        }
        return instance;
    }

    private static Map<String,String> strategyMap = new HashMap<>();
    static{
        for (RefelDbTypeEnum t : RefelDbTypeEnum.values())
            strategyMap.put(t.type(), t.clazz());
    }
    public String strategy(String type){
        return strategyMap.get(type);
    }
}
